#ifndef GAMBATTE_HELP_H
#define GAMBATTE_HELP_H

#include <string>
#include "gambatte.h"
#include "resample/resamplerinfo.h"
#include "PS3Input.h"
#include "PS3Video.h"

#include "utility.h"

using namespace Gambatte;

class GambatteEmu;

class gbblitter : public VideoBlitter
{
	public:
							gbblitter				(GambatteEmu* aEmu);
							~gbblitter				();

		void				setBufferDimensions		(unsigned aWidth, unsigned aHeight);
		const PixelBuffer	inBuffer				();
		void				blit					();

		void				ShowMessage				(std::string aMessage);
		
	protected:
		GambatteEmu*		emulator;
	
		FrameBuffer*		Buffer;
	
		PixelBuffer			buffer;
		
		std::string			message;
		system_time_t		messagetime;
};


class gbinput : public InputStateGetter
{
	public:
		const InputState& 		operator()			()	{return inputs;};

		InputState				inputs;
};

class	GambatteMenu;

class	GambatteEmu
{
	friend class			gbblitter;

	public:
							GambatteEmu				();
							~GambatteEmu			();
							
		void				LoadGame				(std::string aFileName);
		void				Frame					();
		
		void				SaveState				();
		void				LoadState				();
		
		uint32_t			ShouldDraw				(){return Counter.DrawNow();}
		
	protected:
		GB*					gambatte;
		Resampler*			resampler;
		gbblitter*			blitter;
		gbinput*			input;
		
		SettingMenu*		SettingsMenu;
		
		uint32_t			samples[48000];
		uint32_t			resamples[48000];
		int32_t				sampleoverflow;
		
		FastCounter			Counter;
};


#endif